package bomberman.runable;

import bomberman.model.Bom;
import bomberman.util.Constants;

/**
 * 炸弹变化线程，放置一个炸弹新开一个线程控制炸弹大小变化
 * @author EX-FUHUICHAO001
 * 2016年9月22日17:49:04
 */
public class MyRunableBomChange implements Runnable {

	private Bom bom;
	
	public MyRunableBomChange(Bom bom){
		this.bom = bom;
	}
	
	public void run() {
		try {
			// 若炸弹未爆炸，则持续变化炸弹大小
			while(!bom.isBoom()){
				switch (bom.getSize()) {
					case Constants.BOM_SIZE_BIG:
						bom.setSize(Constants.BOM_SIZE_MIDDLE);
						break;
					case Constants.BOM_SIZE_MIDDLE:
						bom.setSize(Constants.BOM_SIZE_SMALL);
						break;
					case Constants.BOM_SIZE_SMALL:
						bom.setSize(Constants.BOM_SIZE_BIG);
						break;
					default:
						break;
				}
				Thread.sleep(Constants.BOM_CHANGE_SLEEP_TIME);
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}


	public Bom getBom() {
		return bom;
	}


	public void setBom(Bom bom) {
		this.bom = bom;
	}
	
}
